package com.huangguolin.cloud.login.control;


import com.alibaba.fastjson.JSON;
import com.huangguolin.cloud.login.service.LoginService;
import com.huangguolin.cloud.mybatis.entity.PtUserEntity;
import com.huangguolin.cloud.spring.control.BaseController;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

@Controller
@RequestMapping("/test")
public class TestController extends BaseController {

    private Logger logger = LogManager.getLogger(this.getClass());
    @Resource
    private LoginService loginService;

    @Secured("ROLE_TEST1")
    @RequestMapping("/test1")
    public String test1page(){
        return "test/test1";
    }

    @Secured("ROLE_TEST2")
    @RequestMapping("/test2")
    public String test2page(){
        return "test/test2";
    }


    @RequestMapping("/queryUserList")
    @ResponseBody
    public List<PtUserEntity> queryUserList(){

        List<PtUserEntity> list = loginService.queryUserList();
        return list;
    }

    @RequestMapping("/deleteUserById")
    @ResponseBody
    public String  deleteUserById(@RequestParam("userId")String userIds){

        logger.info("userId:" + userIds);
        loginService.deleteUserById(userIds);
        return successJSON("user.delete.success");
    }






}
